<?php
/*
*/
include 'collegepress_menu_ads.php';
include 'collegepress_menu_classifieds.php';
include 'collegepress_menu_import.php';

if (!class_exists('CollegePressAdminMenu')) {
class CollegePressAdminMenu {
	var $adminOptionsName = "CollegePressAdminOptions";
	
	function CollegePressAdminMenu(){
		// empty constructor
	}
	
	function CollegePress_ap() {
		//if(function_exists('add_options_page'){
			add_menu_page('College Press', 'College Press', 9, __FILE__, array('CollegePressAdminMenu', 'printAdminPage'));
			add_submenu_page(__FILE__, 'Advertising Control Panel', 'Advertising', 9, 'collegepress_menu_ads.php', 'collegePressAdsAdminPage');
			add_submenu_page(__FILE__, 'Classifieds Control Panel', 'Classifieds', 9, 'collegepress_menu_classifieds.php', 'collegePressClassifiedsAdminPage');//, array('CollegePressAdminMenu', 'printAdminPage'));
			add_submenu_page(__FILE__, 'College Publisher Import Control Panel', 'College Publisher Import', 9, 'collegepress_menu_import.php', 'collegePressImportAdminPage');//, array('CollegePressAdminMenu', 'printAdminPage'));
			//add_options_page('College Press Home', 'College Press Options Home', 7, __FILE__,  array('CollegePressAdminMenu', 'printAdminPage'));
		//}
	}

	function printAdminPage() {
		/* 
		 * $collegepressAdminOptions holds all of the default values for 
		 * options available inside College Press
		 */
		$collegepressAdminOptions = array(
		//$cpOptions = array(
			// enables breaking news functionality
			'enableBreakingNews' 	=> 'true',
			// front page PDF tech
			'enableFrontPagePDF' 	=> 'false',			
			'enableEmailEditions' 	=> 'false',			
			'enableLightbox' 	=> 'true',	
			'enableFlickrImport' 	=> 'true',
			// enables templated section pages
			'enableSectionPages' 	=> 'false',
			// enables templated author pages	
			'enableAuthorPages' 	=> 'true',	
			'enableClassifieds' 	=> 'false',
			'enableAdvertising' 	=> 'false' );
			
		$cpOptions = get_option($adminOptionsName);
		if(!empty($cpOptions)) {
			foreach ($cpOptions as $key => $option)
				$collegepressAdminOptions[$key] = $option;
		}
		update_option($adminOptionsName, $collegepressAdminOptions);

		$cpOptions = $collegepressAdminOptions;
		
		if(isset($_POST['update_collegepressPluginSettings'])) {
			if(isset($_POST['cpBreakingNews']))		{ $cpOptions['enableBreakingNews']	= $_POST['cpBreakingNews'];	}
			if(isset($_POST['cpFrontPagePDF']))		{ $cpOptions['enableFrontPagePDF']	= $_POST['cpFrontPagePDF'];	}
			if(isset($_POST['cpEmailEditions']))	{ $cpOptions['enableEmailEditions'] = $_POST['cpEmailEditions'];}
			if(isset($_POST['cpLightbox']))			{ $cpOptions['enableLightbox']		= $_POST['cpLightbox'];		}	
			if(isset($_POST['cpFlickrImport']))		{ $cpOptions['enableFlickrImport']	= $_POST['cpFlickrImport'];	}
			if(isset($_POST['cpSectionPages']))		{ $cpOptions['enableSectionPages']	= $_POST['cpSectionPages'];	}
			if(isset($_POST['cpAuthorPages']))		{ $cpOptions['enableAuthorPages']	= $_POST['cpAuthorPages'];	}
			if(isset($_POST['cpClassifieds']))		{ $cpOptions['enableClassifieds']	= $_POST['cpClassifieds'];	}
			if(isset($_POST['cpAdvertising']))		{ $cpOptions['enableAdvertising']	= $_POST['cpAdvertising'];	}
							
			update_option($adminOptionsName, $cpOptions);
		
		?>		
		<div class="updated fade"><p><strong><?php _e("Settings Updated.", "CollegePress");?></strong></p></div>
			
		<?php	
		} // end update check 


	
		echo '<div class="wrap">';
		echo '<form method="post" action="'; 
		_e($_SERVER["REQUEST_URI"]);
		echo '">';
		echo '<h2>College Press Control Panel</h2>';

		// RADIO BUTTON TEMPLATE
		/*
		echo '<h3>Enable Breaking News Functionality</h3>';
		echo '<p>Selecting "Yes" will add the "Breaking News" Checkboxes to each post';
		echo '<p><label for="cpBreakingNews_yes"><input type="radio"';
		echo 'id="cpBreakingNews_yes" name="cpBreakingNews" value="true" ';  
		if($cpOptions['enableBreakingNews'] == "true") { _e('checked="checked"', "CollegePress"); }
		echo '/> Yes</label>&nbsp;&nbsp;&nbsp;&nbsp;<label';
		echo 'for="cpBreakingNews_no"><input type="radio" id="cpBreakingNews_no"';
		echo 'name="cpBreakingNews" value="false"'; 
		if ($cpOptions['enableBreakingNews'] == "false") { _e('checked="checked"', "CollegePress"); }
		echo '/> No</label></p>';
		echo '<p>(Default: Yes)</p>';
		*/

		// Breaking News
		echo '<h3>Enable Breaking News Functionality</h3>';
		echo '<p>Selecting "Yes" will add the "Breaking News" checkboxes to each post';
		echo '<p><label for="cpBreakingNews_yes"><input type="radio"';
		echo 'id="cpBreakingNews_yes" name="cpBreakingNews" value="true" ';  
		if($cpOptions['enableBreakingNews'] == "true") { _e('checked="checked"', "CollegePress"); }
		echo '/> Yes</label>&nbsp;&nbsp;&nbsp;&nbsp;<label';
		echo 'for="cpBreakingNews_no"><input type="radio" id="cpBreakingNews_no"';
		echo 'name="cpBreakingNews" value="false"'; 
		if ($cpOptions['enableBreakingNews'] == "false") { _e('checked="checked"', "CollegePress"); }
		echo '/> No</label></p>';
		echo '<p>(Default: Yes)</p>';

		// Lightbox	
		echo '<h3>Enable Lightbox</h3>';
		echo '<p>Selecting "Yes" will make all of your pictures display with Lightbox';
		echo '<p><label for="cpLightbox_yes"><input type="radio"';
		echo 'id="cpLightbox_yes" name="cpLightbox" value="true" ';  
		if($cpOptions['enableLightbox'] == "true") { _e('checked="checked"', "CollegePress"); }
		echo '/> Yes</label>&nbsp;&nbsp;&nbsp;&nbsp;<label';
		echo 'for="cpLightbox_no"><input type="radio" id="cpLightbox_no"';
		echo 'name="cpLightbox" value="false"'; 
		if ($cpOptions['enableLightbox'] == "false") { _e('checked="checked"', "CollegePress"); }
		echo '/> No</label></p>';
		echo '<p>(Default: Yes)</p>';
		
		// Author Pages 
		echo '<h3>Enable Author Pages</h3>';
		echo '<p>Author pages give each of your authors his or her own pre-assembled page. On each page are recent articles from the author, archive of articles from the author, a headshot, and a bio. Selecting "Yes" will turn on Author Pages. Selecting "No" performs the standard Wordpress function of an author URL.';
		echo '<p><label for="cpAuthorPages_yes"><input type="radio"';
		echo 'id="cpAuthorPages_yes" name="cpAuthorPages" value="true" ';  
		if($cpOptions['enableAuthorPages'] == "true") { _e('checked="checked"', "CollegePress"); }
		echo '/> Yes</label>&nbsp;&nbsp;&nbsp;&nbsp;<label';
		echo 'for="cpAuthorPages_no"><input type="radio" id="cpLightbox_no"';
		echo 'name="cpAuthorPages" value="false"'; 
		if ($cpOptions['enableAuthorPages'] == "false") { _e('checked="checked"', "CollegePress"); }
		echo '/> No</label></p>';
		echo '<p>(Default: Yes)</p>';
		
		// Section Pages 
		echo '<h3>Enable Section Pages</h3>';
		echo '<p>Section pages give each of section its own pre-assembled page. On each page are recent articles from the section, archive of section articles, and a description. Selecting "Yes" will turn on Section Pages. Selecting "No" performs the standard Wordpress function of an category URL.';
		echo '<p><label for="cpSectionPages_yes"><input type="radio"';
		echo 'id="cpSectionPages_yes" name="cpSectionPages" value="true" ';  
		if($cpOptions['enableSectionPages'] == "true") { _e('checked="checked"', "CollegePress"); }
		echo '/> Yes</label>&nbsp;&nbsp;&nbsp;&nbsp;<label';
		echo 'for="cpSectionPages_no"><input type="radio" id="cpLightbox_no"';
		echo 'name="cpSectionPages" value="false"'; 
		if ($cpOptions['enableSectionPages'] == "false") { _e('checked="checked"', "CollegePress"); }
		echo '/> No</label></p>';
		echo '<p>(Default: No)</p>';
		

		// Submit Button
		echo '<div class="submit">';
 		echo '<input type="submit" name="update_collegepressPluginSettings"';
    		echo 'value="';
		_e('Update Settings', 'CollegePress') ;
		echo '" /></div>';
 		echo '</form>';

		echo '</div> ';

	} //end printAdminPage()
	

	
} //end CollegePressAdminMenu class
} //end class check
?>
